package com.wee.aircoach_user;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;

/**
 * Created by Solomon on 2015/11/25.
 */
public class CoachSearchActivity extends Activity implements  View.OnClickListener{
  /*  private View coach_search_layout;
    private EditText editCoachId;
    private ListView systemCoachList1;

    private List<Coach> coaches1 = new ArrayList<>();*/

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_coach_search);

        initView();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.back:
                finish();
                break;
        }
    }
    private void initView() {
  /*   findViewById(R.id.back).setOnClickListener(this);
        *//****//*
        editCoachId = (EditText)findViewById(R.id.search_content);
        systemCoachList1 = (ListView)findViewById(R.id.list_1);
        coachAdapter1 = new CoachAdapter(this, coaches1);
        systemCoachList1.setAdapter(coachAdapter1);
        systemCoachList1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Coach coach = coaches1.get(position);
                ModelSingle.getInstance().setModel(coach);
                startActivity(new Intent(CoachSearchActivity.this, CoachInfoActivity.class));
            }
        });

        editCoachId.setSingleLine(true); //android:singleLine=”true”
        editCoachId.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
        editCoachId.setOnEditorActionListener(new TextView.OnEditorActionListener() {

            public boolean onEditorAction(TextView v, int actionId,
                                          KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_SEARCH
                        || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
                    //do something;
                    String coachId = editCoachId.getText().toString();
                    if (coachId.length() != 0) {
                   //     loadCoachById(coachId);
                        DeviceUtil.hideKeyBoard(editCoachId, CoachSearchActivity.this);
                    }
                    return true;
                }
                return false;
            }
        });*/
    }

   /* private void loadCoachById(String id){
        RequestParams params = new RequestParams();
        params.put("code", "" + id);
        params.put("_type", "json");
        AppProgressBar.checkAndCreateProgressBar(this);
        MyApplication.getInstance().getHttpClient().get(Constant.API_GET_COACH_CODE, params, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int i, Header[] headers, byte[] bytes) {
                String json = new String(bytes);
                try {
                    if (new JSONObject(json).optString("status").equals("ok")) {
                        CoachSearchResponse response = new Gson().fromJson(json, CoachSearchResponse.class);
                        if (response != null && response.getData() != null) {
                            //show the result coach searched
                            Coach coach = response.getData();
                            coaches1.clear();
                            ;
                            coaches1.add(coach);
                            coachAdapter1.notifyDataSetChanged();
                        }
                    } else {
                        Toast.makeText(CoachSearchActivity.this, "找不到该编码的教练", Toast.LENGTH_SHORT).show();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();

                }
                AppProgressBar.closeProgressBar();
            }

            @Override
            public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
                throwable.printStackTrace();
                AppProgressBar.closeProgressBar();
                Toast.makeText(CoachSearchActivity.this, "连接服务器失败", Toast.LENGTH_SHORT).show();
            }
        });
    }*/


}
